<?php

use think\migration\Seeder;

class OauthClients extends Seeder
{
    /**
     * Run Method.
     *
     * Write your database seeder using this method.
     *
     * More information on writing seeders is available here:
     * http://docs.phinx.org/en/latest/seeding.html
     */
    public function run():void
    {
        $table = 'oauth_clients';
        $date = date('Y-m-d H:i:s');
        $rows = [
            [
                'id' => 1,
                'name' => '系统内登陆客户端',
                'secret' => sha1(uniqid()),
                'provider' => 'accounts',
                'redirect' => 'http://localhost',
                'password_client' => 1,
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'id' => 2,
                'name' => '工具端',
                'secret' => sha1(uniqid()),
                'provider' => 'accounts',
                'redirect' => 'http://localhost',
                'password_client' => 1,
                'created_at' => $date,
                'updated_at' => $date
            ],
            [
                'id' => 100001,
                'name' => '凭证授予客户端',
                'secret' => sha1(uniqid()),
                'provider' => '',
                'redirect' => '',
                'password_client' => 0,
                'created_at' => $date,
                'updated_at' => $date
            ]
        ];
        $this->table($table)->insert($rows)->save();
    }
}